<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
	
	protected function _initRouter() {
		$this->bootstrap('FrontController');
		$router = $this->getResource('FrontController')->getRouter();
		
		$config = new Zend_Config_Ini(
			APPLICATION_PATH . '/configs/routes.ini',
			APPLICATION_ENV
		);
		
		$router->addConfig($config, 'routes');
	}
	
	protected function _initPreferences() {
		$config = new Zend_Config_Ini(
			APPLICATION_PATH . '/configs/preferences.ini',
			APPLICATION_ENV
		);
		return $config;
	}
	
	protected function _initDoctype() {
		$this->bootstrap('view');
		$view = $this->getResource('view');
		$this->bootstrap('preferences');
		$prefs = $this->getResource('preferences');
		
		$view->doctype('HTML4_STRICT');
		$view->headTitle()->setSeparator(' - ')
			->append($prefs->site->title);
		$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8');
		$view->headLink()->appendStylesheet('/css/screen.css');
	}
	
	protected function _initCache() {
		$this->bootstrap('FrontController');
		$front = $this->getResource('FrontController');
		
		$options = array(
			'frontend' => 'Core',
			'backend' => 'File',
			'frontendOptions' => array(
				'lifetime' => 300,
			),
			'backendOptions' => array(
				'cache_dir' => '/tmp/'
			)
		);
		
		$front->registerPlugin(new Wiki_Controller_Plugin_Cache($options));
	}
	
	protected function _initTranslate() {
		$cache = Zend_Cache::factory(
			'Core',
			'File',
			array(
				'lifetime' => 60*60*3
			),
			array(
				'cache_dir' => '/tmp/',
				'automatic_serialization' => true
			)
		);
		
		Zend_Translate::setCache($cache);
		$translate = new Zend_Translate(
			'csv',
			APPLICATION_PATH . '/translation/',
			null,
			array('scan' => Zend_Translate::LOCALE_DIRECTORY)
		);
		
		Zend_Registry::set('Zend_Translate', $translate);
		
		return $translate;
	}
}